package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseSaleAttr;
import com.atguigu.gmall.model.product.BaseTrademark;
import com.atguigu.gmall.model.product.SpuInfo;
import com.atguigu.gmall.product.service.ManageService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: TODO
 * @Author: Mr.Cao
 * @DateTime: 2021/9/29 19:28
 * BMW F750GS
 **/
@RestController
@RequestMapping("/admin/product")
@Api(tags = "商品SPU接口")
public class SpuManageController {

    @Autowired
    private ManageService manageService;

    /**
     * 获取spu分页列表 : 商品属性Spu
     * */
    @GetMapping("{page}/{limit}")
    public Result selectPageSpuInfo(@PathVariable long page,@PathVariable long limit,
                                    @RequestParam long category3Id){
          IPage<SpuInfo> pageList =  manageService.selectPageSpuInfo(page, limit,category3Id);
        return Result.ok(pageList);
    }
    /**
     * 获取品牌列表 , 用于添加商品属性spu时回显
     * */
    @GetMapping("baseTrademark/getTrademarkList")
    public Result getTrademarkList(){
        List<BaseTrademark> list = manageService.getTrademarkList();
        return Result.ok(list);
    }

    /**
     * 获取销售属性,用于添加商品属性spu时回显
     * */
    @GetMapping("baseSaleAttrList")
    public Result baseSaleAttrList(){
      List<BaseSaleAttr> list =  manageService.baseSaleAttrList();
        return Result.ok(list);
    }


    /**
     * 添加spu 商品列表
     * */
    @PostMapping("saveSpuInfo")
    public Result saveSpuInfo(@RequestBody SpuInfo spuInfo){
        manageService.saveSpuInfo(spuInfo);
        return Result.ok();
    }


}
